from PyCmpltrtok.common import sep
from langchain.prompts import PromptTemplate
from x00100_xquickstart_zh import llm
from x00200_xquickstart_chat_zh import chat_model

sep()
prompt = PromptTemplate.from_template("What is a good name for a company that makes {product}?")
the_prompt = prompt.format(product="medicine")

print(the_prompt)
sep()
xres = llm.invoke(the_prompt)
print(xres)

sep()
from langchain.prompts.chat import ChatPromptTemplate

template = "You are a helpful assistant that translates {input_language} to {output_language}."
human_template = "{text}"

chat_prompt = ChatPromptTemplate.from_messages([
    ("system", template),
    ("human", human_template),
    ("ai", "{trans}"),
    ("human", "{input}"),
    # ('xx', 'Good!'),  # ValueError: Unexpected message type: xx. Use one of 'human', 'user', 'ai', 'assistant', or 'system'.
])

xprompt = chat_prompt.format_messages(
    input_language="Chinese",
    output_language="English",
    text="我爱编程",
    trans="I love programming.",
    input="扁担不让板凳绑在扁担上。",
)
print(xprompt)

sep()
xres = chat_model.invoke(xprompt)
print(xres)
